//
//  RNOLNumPadKeyboardView.m
//  RongNiuOnline
//
//  Created by apple on 2018/4/18.
//  Copyright © 2018年 rongniu. All rights reserved.
//

#import "RNOLNumPadKeyboardView.h"

@interface RNOLNumPadKeyboardView()


@end


@implementation RNOLNumPadKeyboardView

- (NSMutableString *)inputText{
    if (!_inputText) {
        _inputText = [NSMutableString string];
    }
    return _inputText;
}

/// tag: 1~9  10 完成 11: 0  12: x
- (IBAction)clickKeyboardAction:(UIButton *)sender {
    switch (sender.tag) {
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
        case 7:
        case 8:
        case 9:
        case 11:{//纯数字
            if(self.inputText.length == 6){
                return ;
            }
            [self.inputText appendString: sender.currentTitle];
            if ([self.delegate respondsToSelector:@selector(rnol_keyboardInputDidEnd:)]) {
                [self.delegate rnol_keyboardInputDidEnd:sender.currentTitle];
            }
        }
            break;
            
        case 10:{//完成
            if ([self.delegate respondsToSelector:@selector(rnol_keyboardInputComeplete)]) {
                [self.delegate rnol_keyboardInputComeplete];
            }
        }
            break;
            
        case 12:{//删除
            if(self.inputText.length == 0){
                return;
            }
            if ([self.delegate respondsToSelector:@selector(rnol_keyboardInputDeleteBackSpace)]) {
                [self.delegate rnol_keyboardInputDeleteBackSpace];
            }
        }
            break;
        default:
            break;
    }
}

@end

